package vn.com.vega.music.view.adapter;

import vn.com.vega.chacha.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PersonalMusicGridAdapter extends BaseAdapter {
	private static final String[] mListItem = { 
		"Nhạc trong máy", 
		"Yêu thích",
		"Nghe gần đây", 
		"Nhạc đã tải" };
	private static final int[] mListIcon = {
			R.drawable.ic_phone_personal_music,
			R.drawable.ic_liked_personal_music,
			R.drawable.ic_listen_recently_personal_music,
			R.drawable.ic_downloaded_song_personal_music };
	
	private LayoutInflater mInflater;
	
	public PersonalMusicGridAdapter(Context ctx) {
		mInflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mListItem.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ItemHolder holder;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.personal_music_item, null);
			holder = new ItemHolder();
			holder.icon = (ImageView) convertView.findViewById(R.id.imv_icon_image);
			holder.text = (TextView) convertView.findViewById(R.id.tv_ic_name);
			convertView.setTag(holder);
		} else {
			holder = (ItemHolder) convertView.getTag();
		}
		holder.icon.setImageResource(mListIcon[position]);
		holder.text.setText(mListItem[position]);
		
		return convertView;
	}
	
	static class ItemHolder {
		ImageView icon;
		TextView text;
	}

}
